public class main {

	public static void main(String[] args) {
		
		final int NUMER_OF_LOGINS = 65536;
		final int NUMBER_OF_DIGESTS = 65536;
		final int LENGTH_OF_STORED_PW = 8;
		final int LENGTH_OF_LOGIN_PW = 20;
		

		System.out.println("---------------------Precomputation Phase starts---------------------");
		CrackTable ct = new CrackTable();
		PwGen pwg = new PwGen();
		
		String pw="";
		//String digest="";
		
		for(int i=0;i<NUMBER_OF_DIGESTS;i++){
			pw = pwg.generatePW(LENGTH_OF_STORED_PW);
			
			ct.insertKeypair(pwg.generateDigest(pw), pw);
		}
		System.out.println("---------------------Precomputation Phase ended---------------------");


		String login_pw;
		String login_digest;
		int hits=0;
		
		System.out.println("---------------------Login Phase starts---------------------");
		
		for(int logins=0; logins<NUMER_OF_LOGINS;logins++){
			login_pw = pwg.generatePW(LENGTH_OF_LOGIN_PW);
			login_digest = pwg.generateDigest(login_pw);
			
			//System.out.println(login_pw+" --> "+ct.getValue(login_digest));
			if(!ct.getValue(login_digest).equals("null")){
				System.out.println("Treffer bei "+logins);
				System.out.println("LoginPW: "+login_pw+"  ---  LoginDigest: "+login_digest);
				System.out.println("savedPW: "+ct.getValue(login_digest)+"\n");
				hits++;
			}
		}
		System.out.println("---------------------Login Phase ended---------------------");
		System.out.println("Treffer: "+hits);

	}

}
